package com.cmsz.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cmsz.bean.IStore;
import com.cmsz.bean.Store;
import com.cmsz.service.DBService;

@RestController
public class Mycontroller2 {

	@Autowired
	private ApplicationContext applicationContext;

	@Autowired
	ConfigurableApplicationContext configurableApplicationContext;

	@Autowired
	private DBService dBService;
	
	@Autowired
	private IStore store;

	// @Autowired
	// private Store getStore;

	public IStore getStore() {
		return store;
	}

	public void setStore(IStore store) {
		this.store = store;
	}

	@RequestMapping("/store1")
	public String two() {
		System.out.println(applicationContext.getBean("DBService").getClass().getName().toString());
		DBService dBService = (DBService) applicationContext.getBean("DBService");
		dBService.func("zhangsan");
		return "store";
	}

	@RequestMapping("/store")
	public String store() {

		store.func();

		return "store";
	}
}
